package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.sql.Blob;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.Lob;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Tbduefes.
 */
@Configurable
@Entity
@Table(name = "TBDUEFES",schema = "BDUE")
@RooJavaBean
@RooToString
@RooEntity(identifierType = TbduefesPK.class, versionField = "", persistenceUnit="persistenceUnitTLSB", table = "TBDUEFES", schema = "BDUE")
@PersistenceContext(unitName="persistenceUnitTLSB")
@RooDbManaged(automaticallyDelete = true)
public class Tbduefes {

	/** The xti tipenv2. */
	@Column(name = "XTI_TIPENV2", columnDefinition = "CHAR")
    @NotNull
    private Character xtiTipenv2;

	/** The est estadenv. */
	@Column(name = "EST_ESTADENV", columnDefinition = "SMALLINT")
    @NotNull
    private Short estEstadenv;

	/** The fec enviosms. */
	@Column(name = "FEC_ENVIOSMS", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date fecEnviosms;

	/** The tim enviosms. */
	@Column(name = "TIM_ENVIOSMS", columnDefinition = "TIMESTAMP")
    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date timEnviosms;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO", columnDefinition = "CHAR", length = 8)
    @NotNull
    private String audUsuario;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	/** The des sesion. */
	@Column(name = "DES_SESION", columnDefinition = "BLOB")
	@Lob
    private Blob desSesion;

	/** The des servpau. */
	@Column(name = "DES_SERVPAU", columnDefinition = "CHAR", length = 254)
    @NotNull
    private String desServpau;

	/**
	 * Gets the xti tipenv2.
	 *
	 * @return the xti tipenv2
	 */
	public Character getXtiTipenv2() {
        return this.xtiTipenv2;
    }

	/**
	 * Sets the xti tipenv2.
	 *
	 * @param xtiTipenv2 the new xti tipenv2
	 */
	public void setXtiTipenv2(Character xtiTipenv2) {
        this.xtiTipenv2 = xtiTipenv2;
    }

	/**
	 * Gets the est estadenv.
	 *
	 * @return the est estadenv
	 */
	public Short getEstEstadenv() {
        return this.estEstadenv;
    }

	/**
	 * Sets the est estadenv.
	 *
	 * @param estEstadenv the new est estadenv
	 */
	public void setEstEstadenv(Short estEstadenv) {
        this.estEstadenv = estEstadenv;
    }

	/**
	 * Gets the fec enviosms.
	 *
	 * @return the fec enviosms
	 */
	public Date getFecEnviosms() {
        return this.fecEnviosms;
    }

	/**
	 * Sets the fec enviosms.
	 *
	 * @param fecEnviosms the new fec enviosms
	 */
	public void setFecEnviosms(Date fecEnviosms) {
        this.fecEnviosms = fecEnviosms;
    }

	/**
	 * Gets the tim enviosms.
	 *
	 * @return the tim enviosms
	 */
	public Date getTimEnviosms() {
        return this.timEnviosms;
    }

	/**
	 * Sets the tim enviosms.
	 *
	 * @param timEnviosms the new tim enviosms
	 */
	public void setTimEnviosms(Date timEnviosms) {
        this.timEnviosms = timEnviosms;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	/**
	 * Gets the des sesion.
	 *
	 * @return the des sesion
	 */
	public Blob getDesSesion() {
        return this.desSesion;
    }

	/**
	 * Sets the des sesion.
	 *
	 * @param desSesion the new des sesion
	 */
	public void setDesSesion(Blob desSesion) {
        this.desSesion = desSesion;
    }

	/**
	 * Gets the des servpau.
	 *
	 * @return the des servpau
	 */
	public String getDesServpau() {
        return this.desServpau;
    }

	/**
	 * Sets the des servpau.
	 *
	 * @param desServpau the new des servpau
	 */
	public void setDesServpau(String desServpau) {
        this.desServpau = desServpau;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("DesServpau: ").append(getDesServpau()).append(", ");
        sb.append("DesSesion: ").append(getDesSesion()).append(", ");
        sb.append("EstEstadenv: ").append(getEstEstadenv()).append(", ");
        sb.append("FecEnviosms: ").append(getFecEnviosms()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("TimEnviosms: ").append(getTimEnviosms()).append(", ");
        sb.append("XtiTipenv2: ").append(getXtiTipenv2());
        return sb.toString();
    }

	/** The entity manager. */
	@PersistenceContext(unitName="persistenceUnitTLSB")
    transient EntityManager entityManager;

	/** The id. */
	@EmbeddedId
    private TbduefesPK id;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public TbduefesPK getId() {
        return this.id;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(TbduefesPK id) {
        this.id = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlsb")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlsb")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Tbduefes attached = Tbduefes.findTbduefes(this.id);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlsb")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlsb")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the tbduefes
	 */
	@Transactional(value="tlsb")
    public Tbduefes merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Tbduefes merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Tbduefes().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count tbduefeses.
	 *
	 * @return the long
	 */
	@Transactional(value="tlsb")
	public static long countTbduefeses() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Tbduefes o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all tbduefeses.
	 *
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Tbduefes> findAllTbduefeses() {
        return entityManager().createQuery("SELECT o FROM Tbduefes o", Tbduefes.class).getResultList();
    }

	
	/**
	 * Find tbduefes.
	 *
	 * @param id the id
	 * @return the tbduefes
	 */
	@Transactional(value="tlsb")
	public static Tbduefes findTbduefes(TbduefesPK id) {
        if (id == null) return null;
        return entityManager().find(Tbduefes.class, id);
    }

	
	/**
	 * Find tbduefes entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Tbduefes> findTbduefesEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Tbduefes o", Tbduefes.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }
}
